package com.example.neo4j.service.impl;

import com.example.neo4j.node.Country;
import com.example.neo4j.repository.CountryRepository;
import com.example.neo4j.service.CountryService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CountryServiceImpl implements CountryService {

    private final CountryRepository countryRepository;
    public CountryServiceImpl(CountryRepository countryRepository) {
        this.countryRepository = countryRepository;
    }

    @Override
    public List<Country> findAllCountries() {
        return countryRepository.findAll();
    }

    @Override
    public Country findCountryById(Long id) {
        return countryRepository.findById(id).get();
    }

    @Override
    public Country findCountryByName(String name) {
        return countryRepository.findByName(name);
    }
}
